#ifndef QUOTE_LEVEL_SUBSCRIBE_H
#define QUOTE_LEVEL_SUBSCRIBE_H

#include "Tools.h"

#define			QUOTELV_SUBSCRIBE_ID_CANCEL			1			//取消某个订阅ID
#define			QUOTELV_SUBSCRIBE_ID_ALLCANCEL		2			//取消所有订阅
#define			QUOTELV_SUBSCRIBE_ID_REST			3			//重新订阅所有的ID

#define			QUOTELV_SUBSCRIBE_ID_HISMIN			100			//历史订阅ID

typedef struct QUOTELV_SUBSCRIBE_ITEM_tag
{
	TBOOL 			bIsEffective;							//是否有效（FALSE：失效 TRUE：有效）
	char			AskType;								//行情请求类型
	char			HeadType;								//包类型	1 byte	1：全数据包 2：部分数据包
	int				Id;										//订阅Id
	void			*pAsk;									//订阅Id对应的请求结构
	void			*pRes;									//订阅Id对应的应答结构
	char			*pData;									//订阅的数据
	int				nLen;									//订阅数据的长度
	void			*pCBObj;
	int				HttpId;									//非订阅协议的Http请求标记（Socket不用这个字段）
	void(*pResedData)(void *pCBObj, void *p);
	
}QUOTELV_SUBSCRIBE_ITEM;

typedef struct QUOTELV_SUBSCRIBE_LINK_tag
{
	QUOTELV_SUBSCRIBE_ITEM				*pSub;						
	struct QUOTELV_SUBSCRIBE_LINK_tag	*pNext;
	
}QUOTELV_SUBSCRIBE_LINK;

typedef struct QUOTELV_SUBSCRIBE_tag
{
	int									nCount;						//订阅的数量			
	QUOTELV_SUBSCRIBE_LINK				*pLink;
	TBOOL								bLock;			// 软件临界资源对象
	
}QUOTELV_SUBSCRIBE;


/**
 * 功能:
 *		 订阅数组结构初始化
 * 参数:
 *		-
 * 返回值:
 *		无
 */
QUOTELV_SUBSCRIBE* QuoteLvSubscribe_New();

void QuoteLvSubscribe_Del(QUOTELV_SUBSCRIBE* pSubsc);

QUOTELV_SUBSCRIBE_ITEM* QuoteLvSubscribe_AddItem(QUOTELV_SUBSCRIBE* pSubsc, void( *pCallBack )(void *pCBObj, void *p), void *pCBObj,void* aAsk, void *aRes, char *aData, int aLen, int aId, int aHttpId, char aAskType);

void QuoteLvSubscribe_DelAll(QUOTELV_SUBSCRIBE* pSubsc);

QUOTELV_SUBSCRIBE_ITEM* QuoteLvSubscribe_GetItem(QUOTELV_SUBSCRIBE* pSubsc, int aId);

QUOTELV_SUBSCRIBE_ITEM* QuoteLvSubscribe_GetHttpItem(QUOTELV_SUBSCRIBE* pSubsc, int aHttpId);

QUOTELV_SUBSCRIBE_ITEM* QuoteLvSubscribe_GetIndexItem(QUOTELV_SUBSCRIBE* pSubsc, int aIndex);

void QuoteLvSubscribe_ClearInvalidItem(QUOTELV_SUBSCRIBE* pSubsc);

void QuoteLvSubscribe_Lock(QUOTELV_SUBSCRIBE* pSubsc);


void QuoteLvSubscribe_UnLock(QUOTELV_SUBSCRIBE* pSubsc);
#endif